<?=view('header.html')?>

<body class="layui-view-body bgwhite">
    <div class="layui-content" style="margin-bottom: 0px; padding-bottom: 0px;">
        <div class="layui-row">
            <div class="layui-cards">

                <form class="layui-form" method="post" name="myform" id="myform">
                    
                    <div class="layui-form-item">
                        <label class="layui-form-label">会员组：</label>
                        <div class="layui-input-inline">
                            <select name="data[groupid]">
                                <option value="">--请选择--</option>
                                <?php if(isset($groups) && $groups):?>
                                <?php foreach($groups as $g):?>
                                <option value="<?=$g['id']?>" <?php if(isset($data['groupid']) && ($g['id']==$data['groupid'])){echo 'selected';}?>><?=$g['name']?></option>
                                <?php endforeach;?>
                                <?php endif;?>
                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">用户名：</label>
                        <div class="layui-input-inline">
                            <input type="text" value="<?=isset($data['username']) ? $data['username'] : ''?>" name="data[username]" lay-verify="required" placeholder="username" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">密码：</label>
                        <div class="layui-input-inline">
                            <input type="password" value="" name="data[password]" placeholder="登录密码" autocomplete="off" class="layui-input">
                            <div class="layui-form-mid layui-word-aux">编辑修改时，不填 表示不修改密码</div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">手机号：</label>
                        <div class="layui-input-inline">
                            <input type="text" value="<?=isset($data['phone']) ? $data['phone'] : ''?>" name="data[phone]" placeholder="手机号" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">email：</label>
                        <div class="layui-input-inline">
                            <input type="text" value="<?=isset($data['email']) ? $data['email'] : ''?>" name="data[email]" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">姓名：</label>
                        <div class="layui-input-inline">
                            <input type="text" value="<?=isset($data['name']) ? $data['name'] : ''?>" name="data[name]" placeholder="姓名" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">昵称：</label>
                        <div class="layui-input-inline">
                            <input type="text" value="<?=isset($data['nickname']) ? $data['nickname'] : ''?>" name="data[nickname]" placeholder="昵称" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item" lay-filter="status">
                        <label class="layui-form-label">审核状态：</label>
                        <div class="layui-input-inline">
                            <input type="radio" name="data[status]" <?php if((isset($data['status']) && $data['status']==1) || !isset($data['status'])){echo 'checked';}?> value="1" title="已审核">
                            <input type="radio" name="data[status]" <?php if(isset($data['status']) && $data['status']==0){echo 'checked';}?> value="0" title="未审核">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="button" class="layui-btn layui-btn-blue" lay-submit="" lay-filter="ams_submit">提交保存</button>
                        </div>
                    </div>
                </form>

            </div>
        </div>
    </div>
    <?=view('footer.html')?>

    <script type="text/javascript">

        function check_username(username) {
            if (username == '') {
                ams_tips('username', false, '会员名称不能为空');
                isok = false;
            } else {
                $.post('{url("root/check_username")}', { username: username }, function (data) {
                    if (data.code == 0) {
                        ams_tips(data.msg, 1, 1);
                        return true;
                    } else {
                        ams_tips(data.msg, 2, 0);
                        return false;
                    }
                }, 'json')
            }
        }


        layui.use(['layer', 'form', 'jquery'], function () {
            var layer = layui.layer,
                $ = layui.jquery,
                form = layui.form;
            

            //提交
            form.on('submit(ams_submit)', function (data) {
                $.post("", data.field, function (res) {
                    if (res.code == 1) {
                        layer.msg(res.msg, { time: 1500 }, function () {
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index);
                        });
                    } else {
                        layer.msg(res.msg);
                    }
                }, 'json');
                return false;
            });

        });

    </script>
</body>

</html>
